#include <bits/stdc++.h>
using namespace std;
struct zt{
    int id;
    string p;
}a[205];
bool cmp(zt x, zt y){
    int len1 = x.p.size();
    int len2 = y.p.size();
    if (len1 != len2) return len1 > len2;
    return x.p > y.p;
}
int main(){
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i].p;
        a[i].id = i;
    }
    sort(a + 1, a + n + 1, cmp);
    cout << a[1].id << endl << a[1].p;
    return 0;
}